# -*- coding:utf-8 -*-
from fastapi import Request
from core.curd import IBaseService
from app.dao.system import SysRoleDao 
from typing import List


class SysRoleService(IBaseService):

    async def get_role_menu(self, id:int):
        return await self.dao.get_role_menu(id)

    async def get_role_org(self, id:int):
        return await self.dao.get_role_org(id)

    async def select_role_user(self,role_id, page, where):
        return await self.dao.select_role_user(role_id, page, where)

    async def update_datascope(self, post):
        return await self.dao.update_datascope(post)

    async def delete_role_user(self, role_id:int, user_ids:List[int]):
        return await self.dao.delete_role_user(role_id, user_ids)

    @classmethod
    async def instance(cls, req: Request):
        inst = cls()
        inst.dao = await SysRoleDao.instance(req)
        return inst
